package com.lookme.lmtool.cracker.filter.pixellate;

import com.jhlabs.image.CellularFilter;
import com.jhlabs.image.ColorHalftoneFilter;
import com.jhlabs.image.CrystallizeFilter;
import com.lookme.lmtool.cracker.CrackerConstants;
import com.lookme.lmtool.cracker.annotation.FilterAnnotation;
import com.lookme.lmtool.cracker.annotation.ParamAnnotation;
import com.lookme.lmtool.cracker.filter.AbstractFilter;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import java.awt.image.BufferedImageOp;

@FilterAnnotation(groupName = CrackerConstants.FILTER_GROUP_NAME_PIXELLATE,name="晶格化",filterClass = CrystallizeFilter.class)
public class FilterCrystallize extends AbstractFilter {
    @XStreamAsAttribute
    @ParamAnnotation(name = "大小", desc = "大小",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,min=1,max=300,blockIncrement = 5,majorTickUnit=50)
    float scale=32;

    @XStreamAsAttribute
    @ParamAnnotation(name = "网格形状", desc = "网格形状",inputType = ParamAnnotation.InputType.Radio,width = 50,options = {"随机","0","方块","1","六角","2","八角","3","三角","4"})
    int gridType= CellularFilter.SQUARE;

    @XStreamAsAttribute
    @ParamAnnotation(name = "显示边线", desc = "显示边线",inputType = ParamAnnotation.InputType.Radio,width = 80,options = {"显示","false","不显示","true"})
    boolean fadeEdges= false;

    @XStreamAsAttribute
    @ParamAnnotation(name = "边线颜色", desc = "边线颜色",inputType = ParamAnnotation.InputType.ColorPicker)
    int edgeColor=0xffffffff;

    @XStreamAsAttribute
    @ParamAnnotation(name = "边线厚度", desc = "边线厚度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.01f,max=10,min=0.01f,blockIncrement = 5,majorTickUnit=2,minorTickCount = 5)
    private float edgeThickness =0.4f;
//    @XStreamAsAttribute
//    @ParamAnnotation(name = "洋红块角度", desc = "洋红块角度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=360,blockIncrement = 5,majorTickUnit=90,minorTickCount = 3)
//    private float magentaScreenAngle=162;
//    @XStreamAsAttribute
//    @ParamAnnotation(name = "黄色块角度", desc = "黄色块角度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=360,blockIncrement = 5,majorTickUnit=90,minorTickCount = 3)
//    private float yellowScreenAngle=90;

    @Override
    public BufferedImageOp getFilter() {
        CrystallizeFilter filter= new CrystallizeFilter();
        filter.setScale(scale);
        filter.setGridType(gridType);
        filter.setFadeEdges(fadeEdges);
        filter.setEdgeColor(edgeColor);
        filter.setEdgeThickness(edgeThickness);
        return filter;
    }
}
